import { apiClient } from '@/utils/apiClient';

export const AchievmentService = {
    /**
     * 添加成就
     * @param {string} sn - 学号
     * @param {Object} achievmentData - 成就数据
     * @returns {Promise<Object>} 添加结果
     */
    async addAchievments(sn, achievmentData) {
        return apiClient.post(`/api/achievment/addAchievments/${sn}`, achievmentData);
    },

    /**
     * 获取成就列表
     * @param {string} user_sn - 学号
     * @returns {Promise<Object>} 成就列表
     */
    async queryAchievments(user_sn) {
        const params = {};
        if (user_sn) {
            params.user_sn = user_sn;
        }
        return apiClient.get('/api/achievment/getAchievments', params);
    },

    /**
     * 获取单个成就
     * @param {string} id - 成就ID
     * @returns {Promise<Object>} 成就详情
     */
    async getAchievment(id) {
        return apiClient.get(`/api/achievment/${id}`);
    },

    /**
     * 更新成就信息
     * @param {string} id - 成就ID
     * @param {Object} achievmentData - 成就数据
     * @returns {Promise<Object>} 更新结果
     */
    async updateAchievments(id, achievmentData) {
        return apiClient.put(`/api/achievment/${id}`, achievmentData);
    },

    /**
     * 删除成就
     * @param {string} id - 成就ID
     * @returns {Promise<Object>} 删除结果
     */
    async deleteAchievments(id) {
        return apiClient.delete(`/api/achievment/${id}`);
    }
};